home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / virus / stelth22.zip / TESTVIR.C < prev    next >
C/C++ Source or Header  |  1992-02-10  |  4KB  |  123 lines

  1. /*
  2. testvir.c
  3. Stealth Bomber Version 2.2
  4.  
  5. Kevin Dean
  6. Fairview Mall P.O. Box 55074
  7. 1800 Sheppard Avenue East
  8. Willowdale, Ontario
  9. CANADA    M2J 5B9
  10. CompuServe ID: 76336,3114
  11.  
  12. February 10, 1992
  13.  
  14. Files required: TESTVIR.C, VIRCHECK.H, SYSCHECK.C, DOSMCB.H, DOSMCB.C,
  15.         FILECHCK.C, CALCCRC.C, BUFALLOC.C
  16.  
  17.     This program demonstrates the anti-virus CRC algorithms in SYSCHECK.C
  18. and FILECHCK.C.  The response to error codes is entirely up to the programmer.
  19.  
  20.     To set the CRC for this program and its supporting files, the command
  21. is:
  22.  
  23.         crcset -p testvir.exe testvir.obj -d crc.dat testvir.c
  24.  
  25.     This code is public domain.
  26. */
  27.  
  28.  
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31.  
  32. #include "vircheck.h"
  33.  
  34.  
  35. const char *fn[3] =
  36.   {
  37.   "TESTVIR.EXE", "TESTVIR.OBJ", "TESTVIR.C"
  38.   };
  39.  
  40. /* Normally this would be defined by changing STEALTH_NFILES in VIRUSDAT.C to
  41.   3; it has not been done that way for this program as this is a sample file
  42.   only. */
  43. const filecrc _fcrc[3] =
  44.   {
  45.     {
  46.     '_', 'S', 'T', 'E', 'A', 'L', 'T', 'H'
  47.     }
  48.   };
  49.  
  50.  
  51. /***/
  52. int main(int argc, char *argv[])
  53. {
  54. unsigned sysresult, fileresult;
  55. int errfound = 0;
  56. FILE *crcfile;
  57. int i;
  58.  
  59. /* Check system. */
  60. sysresult = stealth_sys_check();
  61.  
  62. if (sysresult & STEALTH_INTR_ERR)
  63.   fputs("System interrupts have been set beyond current code space.  This may indicate\n"
  64.     "the presence of a virus in system memory.\n", stderr);
  65. if (sysresult & STEALTH_DOS_MEM_ERR)
  66.   fputs("Memory reported by DOS is inconsistent with memory reported by BIOS.  This may\n"
  67.     "indicate the presence of a virus in system memory.\n", stderr);
  68. if (sysresult & STEALTH_DOS_HIJACKED)
  69.   fputs("A DOS interrupt has been covertly redirected by another program.  This may\n"
  70.     "indicate the presence of a virus in system memory.\n", stderr);
  71. if (sysresult)
  72.   {
  73.   fputc('\n', stderr);
  74.   errfound = 1;
  75.   }
  76.  
  77. crcfile = fopen("crc.dat", "rb");
  78. if (crcfile)
  79.   {
  80.   fread(_fcrc + 2, sizeof(_fcrc[2]), 1, crcfile);
  81.   fclose(crcfile);
  82.   }
  83. else
  84.   fputs("Error opening CRC.DAT file.\n", stderr);
  85.  
  86. /* Check all files. */
  87. for (i = 0; i < 3; i++)
  88.   {
  89.   if (i || _osmajor < 3)
  90.     fileresult = stealth_file_check(fn[i], _fcrc[i]);
  91.   else
  92.     /* Check main program. */
  93.     fileresult = stealth_file_check(argv[0], _fcrc[i]);
  94.  
  95.   if (fileresult & STEALTH_FILE_ERR)
  96.     fprintf(stderr, "Error accessing %s for CRC check.\n", fn[i]);
  97.   if (fileresult & STEALTH_FILE_DATE_ERR)
  98.     fprintf(stderr, "Date stamp error on file %s.  This may indicate the presence of a\n"
  99.             "virus in the file.  Please take appropriate steps to secure your computer from\n"
  100.             "further possible infection.\n", fn[i]);
  101.   if (fileresult & STEALTH_FILE_SIZE_ERR)
  102.     fprintf(stderr, "File size error on file %s.  This may indicate the presence of a\n"
  103.             "virus in the file.  Please take appropriate steps to secure your computer from\n"
  104.             "further possible infection.\n", fn[i]);
  105.   if (fileresult & (STEALTH_CRC_BAD_POLY | STEALTH_CRC_INVALID))
  106.     fprintf(stderr, "CRC error on file %s.  This file has been tampered with and may be\n"
  107.             "infected by a computer virus.  Please take appropriate steps to secure your\n"
  108.             "computer from further possible infection.\n", fn[i]);
  109.   if (fileresult & STEALTH_NO_MEM)
  110.     fprintf(stderr, "Insufficient memory to run CRC check on file %s.\n", fn[i]);
  111.   if (fileresult)
  112.     {
  113.     fputc('\n', stderr);
  114.     errfound = 1;
  115.     }
  116.   }
  117.  
  118. if (!errfound)
  119.   puts("No viruses found.");
  120.  
  121. return (0);
  122. }
  123.